Crop ================= 类似于slice(张量切片)。不过只支持四维。 输入: - **input** - 输入数据地址。 - **in_shape** - 输入张量形状。 - **out_shape** - 输出张量形状。 - **type_size** - 输入和输出张量数据类型的长度。 - **offset** - 每一维度裁剪开始的偏移量 - **axis** - 裁剪开始的维度 - **core_mask** - 核掩码。 输出: - **output** - 输出地址。 支持平台: ``FT78NE`` ``MT7004`` .. note:: - FT78NE 支持int8, fp32 - MT7004 支持fp16, fp32 **共享/私有存储版本:** .. c:function:: void anytype_crop_anycore(void *input, void *output, int *in_shape, int *out_shape, int type_size, int* offset, int axis, int core_mask) 各种数据类型、私有及共享空间版本均使用该函数。对于不同数据类型,改变type_size参数即可。 **C调用示例:** .. code-block:: c :linenos: :emphasize-lines: 17 void TestCropSMCFp32(int* in_shape, int* out_shape, int axis, int* offset_, int core_mask) { int core_id = get_core_id(); int logic_core_id = GetLogicCoreId(core_mask, core_id); int core_num = GetCoreNum(core_mask); float* input = (float*)0x88000000; // 测试私有空间时地址设置在私有空间内即可 float* output = (float*)0x98000000; int* input_shape = (int*)0xA8000000; int* output_shape = (int*)0xA8200000; int type_size = sizeof(float); int* offset = (int*)0xA8410000; if (logic_core_id == 0) { memcpy(offset, offset_, sizeof(int) * (4 - axis)); memcpy(input_shape, in_shape, sizeof(int) * 4); memcpy(output_shape, out_shape, sizeof(int) * 4); } sys_bar(0, core_num); // 初始化参数完成后进行同步 anytype_crop_anycore(input, output, in_shape, out_shape, type_size, offset, axis, core_mask); } void main(){ int in_shape[4] = {2, 3, 3, 5}; int out_shape[4] = {2, 2, 2, 5}; int axis = 1; int offset[3] = {1, 1, 0}; int core_mask = 0b1111; // 测试单核时核掩码设置为0b0001即可 TestCropSMCFp32(in_shape, out_shape, axis, offset, core_mask); }